package com.vvvtimes.demo.service;

import cn.hutool.core.util.HashUtil;
import cn.hutool.crypto.digest.DigestUtil;
import com.vvvtimes.demo.common.dto.RestResponse;
import com.vvvtimes.demo.domain.dto.DigestDTO;
import org.springframework.stereotype.Service;

@Service
public class DigestService {

    public RestResponse<String> md5(DigestDTO digestDTO) {
        RestResponse<String> result = new RestResponse<>();
        String data = digestDTO.getData();
        String res = DigestUtil.md5Hex(data);
        result.setResult(res);
        return result;
    }

    public RestResponse<String> sha1(DigestDTO digestDTO) {
        RestResponse<String> result = new RestResponse<>();
        String data = digestDTO.getData();
        String res = DigestUtil.sha1Hex(data);
        result.setResult(res);
        return result;
    }
}
